using System;
using System.Web;

namespace NET.Library.Web
{
	/// <summary>
	/// Class Name : Site
	/// Author     : Martin Tomkins
	/// Synopsis   : Class used for website related items
	/// </summary>
	public class Website
	{

		private static string _loginPage;
		/// <summary>
		/// 
		/// </summary>
		public Website()
		{
			//
			// TODO: Add constructor logic here
			//
		}

		/******************************************************************************
		'Property to store login page
		******************************************************************************/
		/// <summary>
		/// 
		/// </summary>
		public static string LoginPage
		{
			get
			{
                return _loginPage;
			}
			set
			{
                _loginPage = value;
			}
		}

		/******************************************************************************
		'Procedure to redirect user to login page
		******************************************************************************/
		/// <summary>
		/// 
		/// </summary>
		public static void LoginRedirect(string LoginPage)
		{
			string strURL;
			strURL =HttpContext.Current.Request.RawUrl;
			strURL = strURL.Replace("/", "%2f");
			//HttpContext.Current.Response.Write(JavaScript.LoginPage(strURL));
			HttpContext.Current.Response.Redirect(LoginPage + "?returnUrl=" + strURL);
		}

        /// <summary>
        /// Returns the web server path and application path as a URL.
        /// </summary>
        /// <returns></returns>
        /// <example>
        /// http://www.rdbrpo.co.uk/
        /// http://localhost/jobshopnet/
        /// </example>
        public static string Path()
        {
            string server = HttpContext.Current.Request.ServerVariables["SERVER_NAME"];
            string appPath = HttpContext.Current.Request.ApplicationPath;
            string path = "http://" + server + appPath + "/";
            if (!path.Contains("localhost"))
            {
                path = path.Substring(0, path.Length - 1);
            }

            return path;
        }
	}
}
